<?php 
/* 
print_r($_FILES); 
print_r($_POST); 
*/

 /* Simple file write
 $File = "YourFile.txt"; 
 $Handle = fopen($File, 'w');
 $Data = "Jane Doe\n"; 
 fwrite($Handle, $Data); 
 $Data = "Bilbo Jones\n"; 
 fwrite($Handle, $Data); 
 print "Data Written"; 
 fclose($Handle); 
 */
 
 /*
 $file = 'monkey.gif';
if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
}
 */
// The good stuff here
Header('Cache-Control: no-cache');
Header('Pragma: no-cache');
$thedirpath = "paste/";
$thefilename = $_GET['KopyKatlistenname'];
//echo "Post file is: " . $thefilename . "</br>";
//$thefilename = "catpaste.txt";
$thefiledefault = $thedirpath . "catpaste.txt";
$pathfile         = $thedirpath . $thefilename;
if ( file_exists($pathfile) ) {
  echo file_get_contents($pathfile);
} else {
   echo file_get_contents($thefiledefault);
}

 // Where the file is going to be placed 
// $target_path = "paste/";

/* Add the original filename to our target path.  
Result is "uploads/filename.extension" */
/*
$target_path = $target_path . basename( $_FILES['thefilename']['name']); 

if(move_uploaded_file($_FILES['thefilename']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['thefilename']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}
*/

 ?>
